package com.leonzhangxf;

import com.leonzhangxf.beta.BetaService;
import com.leonzhangxf.carol.CarolService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author leonzhangxf
 */
@SpringBootApplication
@RestController
@Slf4j
public class WebApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder(WebApplication.class).run(args);
    }

    private BetaService betaService;

    private CarolService carolService;

    @GetMapping("/ping")
    public String ping() {

        String betaResult = betaService.callBeta("ping");
        log.info("beta: {}", betaResult);

        String carolResult = carolService.callCarol("ping");
        log.info("carol: {}", carolResult);
        return "pong";
    }

    @Reference
    public void setBetaService(BetaService betaService) {
        this.betaService = betaService;
    }

    @Reference
    public void setCarolService(CarolService carolService) {
        this.carolService = carolService;
    }
}
